package com.schoolcloud.share.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.schoolcloud.common.model.PageDTO;
import com.schoolcloud.common.model.R;
import com.schoolcloud.share.dto.ShareSetSaveDTO;
import com.schoolcloud.share.entity.VideoSets;
import com.schoolcloud.share.query.VideoSetQuery;
import com.schoolcloud.share.service.VideoSetsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/share/set")
@RequiredArgsConstructor
public class VideoSetController {
    private final VideoSetsService videoSetService;

    @PostMapping
    public R<?> createVideoSet(@RequestBody ShareSetSaveDTO videoSet) {
        videoSetService.createVideoSet(videoSet);
        return R.ok().setMsg("创建成功");
    }
    @PutMapping
    public R<?> updateVideoSet(@RequestBody VideoSets videoSet) {
        videoSetService.updateById(videoSet);
        return R.ok("修改成功！",null);
    }
    @DeleteMapping("/{id}")
    public R<?> deleteVideoSet(@PathVariable Integer id) {
        videoSetService.removeById(id);
        return R.ok();
    }
    @GetMapping("/{id}")
    public R<?> getVideoSet(@PathVariable Integer id) {
        VideoSets videoSet = videoSetService.getById(id);
        return R.ok(videoSet);
    }
    @GetMapping("/page")
    public R<PageDTO<VideoSets>> pageVideoSet(VideoSetQuery query) {
        PageDTO<VideoSets> page = videoSetService.getVideoSetPage(query);
        return R.ok(page);
    }
}
